import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
// 路由管理组件
import { BrowserRouter } from "react-router-dom";

import { PersistGate } from 'redux-persist/integration/react'

import {store,persistor} from './store/index'

import {Provider} from 'react-redux'

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  // <React.StrictMode>
  <BrowserRouter>
  {/* Provider 负责将store传给内层任何一个组件 */}
  <Provider store={store} >
    {/* If you are using react, wrap your root component with PersistGate. This delays the rendering of your app's UI until your persisted state has been retrieved and saved to redux. */}
    {/* 用PersistGate包裹根组件App, 在内部组件渲染完成之前 会自动读取持久化存储的数据并保存到redux中 */}
    <PersistGate loading={null} persistor={persistor}>
      <App />
    </PersistGate>
  </Provider>
</BrowserRouter>
// </React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
